﻿<?php
	session_start();
	include "connect.php";
	
	if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: gv-dangnhap.php");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kết Quả So Sánh</title>
<style type="text/css">

a	{
		color: #006600;
		text-decoration: none;
	}

a:hover { COLOR: #000099}

.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.style3 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style4 {
	color: #000099;
	font-weight: bold;
	font-size:20px;
}
.style5 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 30px;
}
.bg {	border-right-color:#0066FF;
		border-bottom-color:#0066FF;
	}

.bg1 {	border-bottom-color:#0066FF;}

.bg2 {	border-top-color:#0066FF;}

.bg3 {	border-left-color:#0066FF;}

.bg4 {	border-right-color:#0066FF;}
.mo	{	color:#0000FF;	}
.style6 {
	
	color: #000099;
}
.style7{
	font-size: 20px;
	font-weight: bold;
}
</style>
<script language="javascript">
	function openUrl(a)
	{
		var win = window.open(a,'Buy ticket',
			'width=' + 1400 + ', height=' + 900 + ', ' +
			'left=' + 0 + ', top=' + 0 + ', ' +
			'location=no, menubar=no, ' +
			'status=no, toolbar=no, scrollbars=yes, resizable=no');
	}
</script>
</head>
<body>
<?php
         if($_GET["act"] == "in")
		  {
			$magv = $_GET["magv"];
		  }
		  else
		  {
			$magv=$_SESSION['gv'];
		  }
        
        $hknk1=$_REQUEST["ma1"];$hknk2=$_REQUEST["ma2"];
	    $mahp=$_REQUEST["mahp"];
	  
	    

		$sql = mysql_query("Select a.ma_gv,a.ten_gv,  c.ten_khoa,c.ma_khoa FROM `giang vien` a,  `khoa` c,`bo mon` d where a.ma_gv='$magv' and  a.ma_bm=d.ma_bm and d.ma_khoa=c.ma_khoa") ;		
		while($rows = mysql_fetch_array($sql))
		{
			$msgv=$rows["0"];
			$tengv=$rows["1"];
			$tenkhoa=$rows["2"];
			$makhoa=$rows["3"];
			
			
	    }
	  
	  $tam=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk1' ");
	  $t=mysql_fetch_row($tam);
	  $hk1=$t[1];$nk1=$t[2];
	  $tam1=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk2' ");
	  $t1=mysql_fetch_row($tam1);
	  $hk2=$t1[1];$nk2=$t1[2];
	  
	  $str=mysql_query("select ten_hp from `hoc phan` where ma_hp='$mahp'");
	  $st=mysql_fetch_row($str);
	  $tenhp=$st[0];
	  
	  
?>
<!-- đầu trang --> 	
<?php
		            $kq=mysql_query("select extract(day from curdate()),extract(month from curdate()),extract(year from curdate()) "); 
					while ($r=mysql_fetch_row($kq))
					{
						$ngay=$r[0];
						$thang=$r[1];
						$nam=$r[2];
					}
		  ?>  
<?php // convert image to dataURL
$img_source = "image/logo.gif"; // image path/name
$img_binary = fread(fopen($img_source, "r"), filesize($img_source));
$img_string = "data:image/gif;base64,".base64_encode($img_binary);
?>

<div align="right">
	<a href="#" onclick="openUrl('exportPDF.php<?php echo "?type=gvsskqlophp&magv=".$magv."&ma1=".$_REQUEST["ma1"]."&mahp=".$_REQUEST["mahp"]."&ma2=".$_REQUEST["ma2"]."&act=in"; ?>');"/>Mẫu In  <?php echo $ngay; ?>/<?php echo $thang; ?>/<?php echo $nam; ?></a></div>
	<tr> <td width="900">
   	  <table width="100%" border="0">
          
          <tr>
		    <td  rowspan="2" width="100" style="border:none"><img src="<?php echo $img_string; ?>" height="70" width="100" /></td>
            <td colspan="2" style="border:none"><div align="left" style="font-size:18px; font-weight:bold" class="style6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRƯỜNG ĐẠI HỌC CẦN THƠ</div></td>
            <td colspan="3" style="border:none"><div align="center" style="font-size:18px; font-weight:bold;" class="style6">CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</div></td>
          </tr>
          
          <tr>
            <td colspan="2" style="border:none"><div align="left" style="font-size:18px; font-weight:bold;" class="style6">Khoa <?php echo $tenkhoa; ?> </div></td>
            <td colspan="3" style="border:none"><div align="center" style="font-size:18px; font-weight:bold" class="style6" >Độc lập - Tự do - Hạnh phúc </div></td>
          </tr>
          
          <tr>
            <td width="100" style="border:none">&nbsp;</td>
			<td width="294" style="border:none" >&nbsp;</td>
			<td width="131" style="border:none" >&nbsp;</td>
            <td width="215" style="border:none">&nbsp;</td>
            <td width="108" class="bg2" style="border:none">&nbsp;</td>
            <td width="218" style="border:none">&nbsp;</td>
          </tr>
                    
          <?php   
								       $up=mysql_query("select upper('$tengv') from dual");
									   $up1=mysql_fetch_row($up);
									   $ten=$up1[0];
									   
		 ?>
          <tr>
            <td height="40" colspan="6"  style="font-size:25px; font-weight:bold; border:none;" class="style6" align="center" valign="bottom">
			     KẾT QUẢ SO SÁNH LỚP HỌC PHẦN CỦA GIẢNG VIÊN <?php echo $ten; ?>
            </td>
          </tr>
		  <tr>
            <td height="40" colspan="6"  style="font-size:25px; font-weight:bold; border:none;" class="style6" align="center" valign="bottom">
			     Học Phần: <?php echo $tenhp; ?>
            </td>
          </tr>
		  <tr>
            <td height="50" colspan="6"  style="font-size:20px; font-weight:bold; border:none" class="style6" align="center" valign="top">
			   Từ  Học Kì <?php echo $hk1; ?> (<?php echo $nk1; ?>) - Đến  Học Kì <?php echo $hk2; ?> (<?php echo $nk2; ?>)
            </td>
          </tr>
         
						
		  
						 <tr valign="top">
							<td height="15" colspan="6" style="border:none"> </td>
							
						</tr>
		
						 <tr valign="top">
							<td height="30" colspan="6">
											 <table width="1200" align="center" cellspacing="0" border="1" bordercolor="#0066FF" cellpadding="0">
											
											
															
											<tr align="center"  bgcolor="#CCCCCC">
												<td  height="20"  rowspan="2" ><span class="style7">STT</span>				
												</td>
												<td  height="20"  rowspan="2" ><span class="style7">Lớp Học Phần</span>				
												</td>
												<td   colspan="2"><span class="style7">Chưa Hài Lòng</span>			   
												</td>
												<td   colspan="2">
														  <span class="style7">Hài Lòng</span>				
												</td>
												<td   colspan="2">
														  <span class="style7">Rất Hài Lòng</span>				
												</td>
												<td   colspan="2">
														  <span class="style7">Xuất Sắc</span>				
												</td>
												<td  height="20"  rowspan="2" ><span class="style7">Học Kì</span>				
												</td>
												<td  height="20"  rowspan="2" ><span class="style7">Niên Khóa</span>				
												</td>
												
											</tr>
											<tr bgcolor="#CCCCCC">
											     
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 
											</tr>
								 <?php
		                $khl=array();
						$hl=array();
						$rhl=array();
						$xs=array();
		           
					
					    $q=mysql_query("select * from `lop hoc phan` where ma_gv='$magv' and ma_hp='$mahp' and ma_hknk between $hknk1 and $hknk2");
													   while( $q1=mysql_fetch_row($q))
													   {
													            $dem++;			
																$stt=$q1[2];
																$hknk=$q1[1];
																$sql=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk'");
																$a=mysql_fetch_row($sql);
																$hk=$a[1];
																$nk=$a[2];
																$demsv=0;
															   $truyvan=mysql_query("select * from `danh gia` where ma_hknk='$hknk' and stt_nhom='$stt' and ma_hp='$mahp' group by ma_sv,ma_hknk,stt_nhom,ma_hp");
															   while ($tv=mysql_fetch_row($truyvan))
															   {
																	  $demsv++;
															   }
																
																$sql1=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where  a.ma_hknk='$hknk' and `muc danh gia`='1' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and a.stt_nhom='$stt'  group by `muc danh gia`");
															    $sql2=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk' and `muc danh gia`='2' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and a.stt_nhom='$stt' group by `muc danh gia`");
																$sql3=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk'  and `muc danh gia`='3' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and a.stt_nhom='$stt' group by `muc danh gia`");
															    $sql4=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk' and `muc danh gia`='4' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and a.stt_nhom='$stt' group by `muc danh gia`");
															   if(mysql_num_rows($sql1)==0) $muc1=0;
																   else
																   {
																   $r1=mysql_fetch_row($sql1);
																   $muc1=$r1[1];
																   }
																   if(mysql_num_rows($sql2)==0) $muc2=0;
																   else
																   {
																   $r2=mysql_fetch_row($sql2);
																   $muc2=$r2[1];
																   }
																   if(mysql_num_rows($sql3)==0) $muc3=0;
																   else
																   {
																   $r3=mysql_fetch_row($sql3);
																   $muc3=$r3[1];
																   }
																   if(mysql_num_rows($sql4)==0) $muc4=0;
																   else
																   {
																   $r4=mysql_fetch_row($sql4);
																   $muc4=$r4[1];
															   }
						   ?>
						   <tr >
						       <td  height="40" style="font-size:20px;" align="center">
							         <?php echo $dem; ?> 
							   </td>
							   <td style="font-size:20px" align="center">
							        <?php
																				   
								          echo $mahp;echo $hknk;echo $stt;
									?>
							   </td>
							   
							   <td align="center" style="font-size:20px">
							          <?php echo $muc1; ?>
							   </td>
					
							   <td  align="center" style="font-size:20px">
							        <?php
									if ($demsv != 0)
									{
									      $t=($muc1/($demsv*11))*100;
										  $t1=round($t,2);
										  $khl[]=$t1; 
										  echo " $t1 %  ";
									}
									else echo "0 %";
									?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc2; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							       <?php
									if ($demsv != 0)
									{
										  $t=($muc2/($demsv*11))*100;
										  $t1=round($t,2);
										  $hl[]=$t1; 
										  echo " $t1 %  ";
									}
									else echo "0 %";
									?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc3; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							          <?php
									if ($demsv != 0)
									{
										  $t=($muc3/($demsv*11))*100;
										  $t1=round($t,2); 
										  $rhl[]=$t1;
										  echo " $t1 %  ";
									}
									else echo "0 %";
									 ?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc4; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							          <?php
									if ($demsv != 0)
									{
									       $t=($muc4/($demsv*11))*100;
										  $t1=round($t,2);
										  $xs[]=$t1; 
										  echo " $t1 %  ";
									}
									else echo "0 %";
									?>
							   </td> 
							   <td  align="center" style="font-size:20px;">
																			 <?php
																				  
																				   echo $hk;
																			 ?>
								 </td>
								 <td  align="center" style="font-size:20px;">
																			 <?php
																				  
																				   echo $nk;
																			 ?>
								</td>
							     
                           </tr>
						   <?php
						      
						}//while
						 
					 
		   ?>
										  
										   </table>
							         </td>
						   
						</tr>
						<tr valign="top">
							<td height="20" colspan="6" style="border:none"> </td>
							
						</tr>
			
      </table>
    </td> 
	</tr>

</body>
</html>




